package cn.ainit.model;


import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/modelPages")
public class ModelController {
	private ModelService modelService;
	
	@Resource
	public void setModelService(ModelService modelService) {
		this.modelService = modelService;
	}
	
	
	@RequestMapping("/jisuan")
	@ResponseBody
	public String userLogin(String name, Integer age, HttpServletRequest request){
		System.out.println(name+":"+age+"岁");
		if (name.equals("张三") && age == 12) {
			System.out.println("success");
		}
		return "test/test1";
	}
	
	@RequestMapping("/ZY")
	@ResponseBody
	public String add(String fn,String sn, HttpServletRequest request) throws Exception{
		int fni,sni;
		try{
			 fni=Integer.parseInt(fn);
			 sni=Integer.parseInt(sn);
			}
		catch(Exception e){
				System.out.println("字符串转换为整型失败");
				e.printStackTrace();
				return "1";
		}
		return String.valueOf(fni+sni);
	}
 
	@RequestMapping("/TESTSUB")
	@ResponseBody
	public String sub(String m1,String m2, HttpServletRequest request) throws Exception{
		int mm1,mm2;
		try{
			 mm1=Integer.parseInt(m1);
			 mm2=Integer.parseInt(m2);
			}
		catch(Exception e){
				System.out.println("字符串转换为整型失败");
				e.printStackTrace();
				return "a";
		}
		return String.valueOf(mm1-mm2);
	}
	
}
